let types = require('../constants');
let tokenTypes = require('../common/token-types');
let commandModule = require('../modules/command-module');

let commandUtil = {
  parsePosNode(operaValue, refValue) {
    let type = operaValue.includes(types.POS_IDENTIFIER.AFTER) ? types.POS_TYPE.AFTER : types.POS_TYPE.BEHIND;
    let force = operaValue.length == 2;
    return new commandModule.Pos(type, refValue, force);
  },
  getAssignScope(node) {
    let opera = node.operator;
    if (opera.value == '=') {
      let targetOpera = node.left.operator;
      if (targetOpera.type == tokenTypes.DOT) {
        return types.PROPERTY_SCOPE.INARGS;
      } else if (targetOpera.type == tokenTypes.DOLLOR) {
        return types.PROPERTY_SCOPE.OTHER;
      }
    } else {
      return types.PROPERTY_SCOPE.OUTARGS;
    }
  }
};

module.exports = commandUtil;
